package Railroad.Components;

// Trieda definuje všetky vlastnosti koľají.

public class Rail extends TrackNode {
    private final int startX;
    private final int startY;
    private final int endY;
    private final int endX;
    private final String name;
      
    public Rail(int id,int startX,int startY,int endX,int endY, String name) {
        super(id);
        super.setBusy(false);
        this.startX = startX;
        this.startY = startY;
        this.endY = endY;
        this.endX = endX;
        this.name = name;
    }

    // Gettre na zistenie koncovej x,y-ovej súradnice a x,y-ovej štarovej súradnice.
    public int getEndX() {
        return endX;
    }

    public int getEndY() {
        return endY;
    }

    public int getStartX() {
        return startX;
    }

    public int getStartY() {
        return startY;
    }
    
    public String getName() {
        return name;
    }
    
    @Override
    public boolean isOnXY(int x, int y){
        return x >= Math.min(startX, endX) && x <= Math.max(startX, endX) &&
                y >= Math.min(startY, endY) && y <= Math.max(startY, endY);
    }
}